package com.tyl.bk;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
/**
 *不抛出异常
 **/
//队列
public class BlockingQueueTest2 {

    public static void main(String[] args) {
        BlockingQueue blockingQueue= new ArrayBlockingQueue<>(3);
        System.out.println(blockingQueue.offer("a"));
        System.out.println(blockingQueue.offer("b"));
        System.out.println(blockingQueue.offer("c"));
        System.out.println(blockingQueue.offer("d"));//队列满后插入返回false
        System.out.println("=============================");
        System.out.println(blockingQueue.poll());
        System.out.println(blockingQueue.poll());
        System.out.println(blockingQueue.poll());
        System.out.println(blockingQueue.poll());//队列空后返回null
    }
}

